#include "front/text_normalize.h"

using namespace std;
using namespace ppspeech;

const wregex mcWregexComma(L"\\d+,\\d+(,\\d+)*");

// XX,XX		09:11 --> 九点十一分
void TextNormalizer::TnReComma(wstring* fpInWsentence, const LanguageEnum fcInLanguage)
{
	wsmatch tWsmatch;

	while(regex_search(*fpInWsentence, tWsmatch, mcWregexComma))
	{
		string tStrReplace = "";
		string tStrComma = wstring2utf8string(tWsmatch[0]);		//匹配到逗号的字符串
		vector<string> tItemComma = StrSplit(tStrComma, ",");	//按逗号分开
		size_t tItemTotal = tItemComma.size();

		//超过两项的情况，__,__,__，去空格，采用数字读法。
		if(tItemTotal > 2) {
			StrReplace(tStrComma, ",", "");
			tStrReplace = tStrComma;
		}
		//等于2项的情况，__,__，；特殊地985,211读九八五二幺幺。
		else if(tItemTotal == 2) {
			if(tItemComma[0] == "985" && tItemComma[1] == "211") {
				tStrReplace = ReplaceMethod(tItemComma, (fcInLanguage==LANG_EN)?RME_en_telephone:RME_zh_telephone);
			}
			else {
				StrReplace(tStrComma, ",", "");
				tStrReplace = tStrComma;
			}
		}

		WstrReplacePosition(fpInWsentence, tWsmatch.position(0), tWsmatch.length(0), utf8string2wstring(tStrReplace));
	}
}